package com.dailyblue.java.design.单例模式;

import lombok.SneakyThrows;

// 懒汉单例模式
public class DemoB {

    private static DemoB instance;

    private DemoB() {
    }

    @SneakyThrows
    public static DemoB getInstance() {
        // 保证第一次调用时 产生对象
        if (instance == null) {
            // 会出现问题
            Thread.sleep(1000);
            instance = new DemoB();
        }
        return instance;
    }

}
